<template>
  <div>
    <h3>{{msgFromChild}}</h3>
    <input v-model="text" @change="$emit('exchangeInput', text)" placeholder="请输入" />
    <button @click="clearInput">清空</button>
    <button @click="$emit('addList', text)">提交</button>
    <button @click="$emit('removeAll')">数据重置</button>
  </div>
</template>
<script>
import { onMounted, ref } from 'vue'
// 事件引入
import bus from 'vue3-eventbus'
export default {
  setup() {
    const msgFromChild = ref("")
    onMounted(()=>{
      bus.on("getMsg", (msg) => {
        console.log(msg)
        //接受Child发来的消息
        msgFromChild.value = msg
      })
    })
    return {
      msgFromChild
    }
  },
}
</script>